function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}
function ltrim(stringToTrim) {
	return stringToTrim.replace(/^\s+/,"");
}
function rtrim(stringToTrim) {
	return stringToTrim.replace(/\s+$/,"");
}

function CheckEmailRegExpression(emailID)
{       
    var emailRegxp = new RegExp("^([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)");
        
    //THIS IS THE KEY TO THE RegX expression. Remember, you need to check the string value.
    //Also, remember to escape the \ characters with another slash. \\
    //var emailRegxp = new RegExp("^\\d{5}");
    var boolValue = emailRegxp.test(emailID);
        
    if ( !boolValue )    
    {
        return false;
    }
    return true;        
}	

function SetFocus(divSubscribe, imgSubscribe)
{    
    var divEmailMsg = document.getElementById("divInsiderAlertsEmail");
    if (divEmailMsg.style.display != "none")    
    {
        var emailID = GetCurrentControlObject(divSubscribe,imgSubscribe);  
        if ( emailID != undefined )
        {           
            emailID.focus();
        }
    } 
    
}
	
function ProcessBlankEmail()
{    

		var divErrorMsg = document.getElementById("divDisplayErrorMessages");
		divErrorMsg.style.display= "";
		
		var divEmailErrorMsg = document.getElementById("divEmailAddressIsARequiredField");
		divEmailErrorMsg.style.display="";
		
		var divEmailMsg = document.getElementById("divInsiderAlertsEmail");
		divEmailMsg.style.display= "none";	
		
}	



function ProcessInvalidEmail()
{    
        
		var divErrorMsg = document.getElementById("divDisplayErrorMessages");		
		divErrorMsg.style.display= "";
		var divEmailErrorMsg = document.getElementById("divErrorEmailAddressInvalid");
		divEmailErrorMsg.style.display="";
		
		var divEmailMsg = document.getElementById("divInsiderAlertsEmail");
		divEmailMsg.style.display= "none";		
		
}	


function ValidateEMail(emailID)
{
    
    if ((emailID==null)||(emailID==""))
	{	   
	    ProcessBlankEmail();	    
		return false;		
	}
	
	if ( CheckEmailRegExpression(emailID) == false)
	{	  	    
	    ProcessInvalidEmail();
		return false;
	}	
	
	return true;
}

function ProcessInvalidTeamChoice()
{    
        
		var divErrorMsg = document.getElementById("divDisplayErrorMessages");		
		divErrorMsg.style.display= "";
		var divEmailErrorMsg = document.getElementById("divChooseATeam");
		divEmailErrorMsg.style.display="";
		
		var divEmailMsg = document.getElementById("divInsiderAlertsEmail");
		divEmailMsg.style.display= "none";		
		
}	

function CheckPhoneRegExpression(phone)
{       
    
    var phoneRegxp = new RegExp("^\\d{10}$");
        
    //THIS IS THE KEY TO THE RegX expression. Remember, you need to check the string value.
    //Also, remember to escape the \ characters with another slash. \\
    //var emailRegxp = new RegExp("^\\d{5}");
    var boolValue = phoneRegxp.test(phone);
        
    if ( !boolValue )    
    {
        return false;
    }
    return true;        
}	

function ProcessInvalidMobilePhone()
{    
        
		var divErrorMsg = document.getElementById("divDisplayErrorMessages");		
		divErrorMsg.style.display= "";
		var divEmailErrorMsg = document.getElementById("divMobilePhoneIsInvalid");
		divEmailErrorMsg.style.display="";
		
		var divEmailMsg = document.getElementById("divInsiderAlertsEmail");
		divEmailMsg.style.display= "none";		
		
}	

function ValidateMobilePhone(phone)
{
    if ( CheckPhoneRegExpression(phone) == false)
	{	  	    
	    ProcessInvalidMobilePhone();
		return false;
	}	
	return true;
}

function ValidateAreaCodeMobilePhone(phone)
{
	
	var phoneRegxp = new RegExp("^\\d{3}$");
        
    //THIS IS THE KEY TO THE RegX expression. Remember, you need to check the string value.
    //Also, remember to escape the \ characters with another slash. \\
    //var emailRegxp = new RegExp("^\\d{5}");
    var boolValue = phoneRegxp.test(phone);
        
    if ( !boolValue )    
    {
        ProcessInvalidMobilePhone();
		
        return false;
    }
    return true;  
}

function ValidateMobilePhoneNumber(phone)
{
    var phoneRegxp = new RegExp("^\\d{4}$");
        
    //THIS IS THE KEY TO THE RegX expression. Remember, you need to check the string value.
    //Also, remember to escape the \ characters with another slash. \\
    //var emailRegxp = new RegExp("^\\d{5}");
    var boolValue = phoneRegxp.test(phone);
        
    if ( !boolValue )    
    {
        ProcessInvalidMobilePhone();
        return false;
    }
    return true;  
}

function ValidateExchangeMobilePhone(phone)
{
    var phoneRegxp = new RegExp("^\\d{3}$");    
        
    //THIS IS THE KEY TO THE RegX expression. Remember, you need to check the string value.
    //Also, remember to escape the \ characters with another slash. \\
    //var emailRegxp = new RegExp("^\\d{5}");
    var boolValue = phoneRegxp.test(phone);
        
    if ( !boolValue )    
    {
        ProcessInvalidMobilePhone();
        return false;
    }
    return true;  
}

function CheckZipCodeRegExpression(eZipCode)
{                  
    //THIS IS THE KEY TO THE RegX expression. Remember, you need to check the string value.
    //var emailRegxp = new RegExp("^\\d{5}");
    //Also, remember to escape the \ characters with another slash. \\
    //This regular expression checks for both US and Canadian Zips    
   // var zipRegExp = new RegExp("^(\\d{5})([- ])?(\\d{4})?|^([a-zA-Z]\\d[a-zA-Z][\\- ]?\\d[a-zA-Z]\\d)|^([A-Za-z]{1,2}[0-9A-Za-z]{1,2}[ ]?[0-9]{0,1}[A-Za-z]{2})");
      var zipRegExp = new RegExp("^(\\d{5})([- ])?(\\d{4})?|^([a-zA-Z]\\d[a-zA-Z][\\- ]?\\d[a-zA-Z]\\d)|^([A-Za-z]{1,2}[0-9A-Za-z]{1,2}[ ]?[0-9]{0,1}[A-Za-z]{2})");
    var boolValue = zipRegExp.test(eZipCode);   
        
    if ( !boolValue )    
    {
        return false;
    }    
    return true;        
}	

function CheckZipCode(eZipCode)
{     
    //Check for US Zip Code
        
    //var emailRegxp = new RegExp("(^\\d{5}$)|(^\\d{5}-\\d{4}$)");
//    var emailRegxp = new RegExp("(^\\d{5}$)");
//    var boolValue = emailRegxp.test(eZipCode);
//    
//    if ( boolValue )
//    {
//        return true;
//    }

    //Validation for US & Canadian Postal Codes
    var zipRegExp = new RegExp("^(\\d{5}(( |-)\\d{4})?)|([A-Za-z]\\d[A-Za-z]( |-)\\d[A-Za-z]\\d)$"); //^\\D{1}\\d{1}\\D{1}\\-?\\d{1}\\D{1}\\d{1}$
    var boolValue = zipRegExp.test(eZipCode);   
        
//    if ( !boolValue )    
//    {
//        return false;
//    }
    //    return true;
    return boolValue;
}	

function ProcessBlankZipCode()
{    
		var divErrorMsg = document.getElementById("divDisplayErrorMessages");
		divErrorMsg.style.display= "";
		var divEmailErrorMsg = document.getElementById("divZipCodeIsARequiredField");
		divEmailErrorMsg.style.display="";
		var divEmailMsg = document.getElementById("divInsiderAlertsEmail");
		divEmailMsg.style.display= "none";		
}	

function ProcessInvalidZipCode()
{    
		var divErrorMsg = document.getElementById("divDisplayErrorMessages");
		divErrorMsg.style.display= "";
		var divEmailErrorMsg = document.getElementById("divErrorZipCodeInvalid");
		divEmailErrorMsg.style.display="";
		var divEmailMsg = document.getElementById("divInsiderAlertsEmail");
		divEmailMsg.style.display= "none";		
}	


function ValidateZipCode(eZipCode)
{

     
    if ((eZipCode==null)||(eZipCode==""))
	{	   
	    ProcessBlankZipCode();	    
		return false;		
	}
	
	if ( CheckZipCode(eZipCode) == false)
	{
	    ProcessInvalidZipCode();
		return false;
	}	
	
//	if ( CheckZipCodeRegExpression(eZipCode) == false)
//	{
//	    ProcessInvalidZipCode();
//		return false;
//	}	


	
	
	
    
	return true;
}

function ProcessBlankUserName()
{    
		var divErrorMsg = document.getElementById("divDisplayErrorMessages");
		divErrorMsg.style.display= "";
		var divEmailErrorMsg = document.getElementById("divUserNameIsARequiredField");
		divEmailErrorMsg.style.display="";
		var divEmailMsg = document.getElementById("divInsiderAlertsEmail");
		divEmailMsg.style.display= "none";		
}	

function ValidateUserName(eUserName)
{
    if ((eUserName==null)||(trim(eUserName)==""))
	{	   
	    ProcessBlankUserName();	    
		return false;		
	}
	return true;
}

function GetCurrentControlValue( divName, controlName )
{    
    var divID=document.getElementById(divName);
       
    var returnValue = undefined;
      
    for ( var i = 0; i < divID.childNodes.length; i++)
    {
        
        if  ( divID.childNodes[i].id != undefined )
        {            
            if ( divID.childNodes[i].id.indexOf(controlName) != -1 )
            {
                var returnValue = divID.childNodes[i].value;
               
//                //This is the javascript version of replaceall
//                returnValue = tempVar.replace(/_/g,"$");
                
            }
        }
    }   
    return returnValue;   
           
}

function GetCheckBox( divName, controlName )
{

    var divID=document.getElementById(divName);
    
    var returnValue = undefined;
           
    for ( var i = 0; i < divID.childNodes.length; i++)
    {
        
        if  ( divID.childNodes[i].id != undefined )
        {            
            if ( divID.childNodes[i].id.indexOf(controlName) != -1 )
            {
                var returnValue = divID.childNodes[i].checked; 
                return returnValue;                              
            }
        }
    }   
    return returnValue;   
           
}

function GetCurrentControlObject( divName, controlName )
{

    var divID=document.getElementById(divName);
    
    var returnValue = undefined;
    //alert(controlName);            
    for ( var i = 0; i < divID.childNodes.length; i++)
    {
        
        if  ( divID.childNodes[i].id != undefined )
        {    
              
            //alert(divID.childNodes[i].id);
            //if ( divID.childNodes[i].id == controlName)
            if ( divID.childNodes[i].id.indexOf(controlName) != -1 )
            {
               // var returnValue = divID.childNodes[i].name;
               
               var returnValue = divID.childNodes[i];
               //alert(returnValue.id);
               return returnValue;
               
//                //This is the javascript version of replaceall
//                returnValue = tempVar.replace(/_/g,"$");
                
            }
        }
    }   
    return returnValue;   
           
}

function ValidateForm() {

    if (document.getElementById("divMobileNumber") != undefined) {
        var chkMobileNumber = GetCheckBox("divMobileNumber","chkMobileNumber");
        if ( chkMobileNumber == true )
        {
                   var eAreaCode = GetCurrentControlValue("divMobileNumber","txtMobilePhoneAreaCode");
                   var eExchange = GetCurrentControlValue("divMobileNumber","txtMobilePhoneExchange");
                   var ePhoneNumber = GetCurrentControlValue("divMobileNumber","txtMobilePhoneLast4Digits");
                   if (( eAreaCode == "" ) || (eExchange == "") || (ePhoneNumber == "") )
                   {
                       ProcessInvalidMobilePhone();
                       return false;
                   }
               }
                
                
                var eAreaCode = GetCurrentControlValue("divMobileNumber","txtMobilePhoneAreaCode");
                if ( eAreaCode != "" ) 
                {
        	        if ( !ValidateAreaCodeMobilePhone( eAreaCode ))
        	        {
        	            return false;
        	        }
        	    }	
        	    
       	    var eExchange = GetCurrentControlValue("divMobileNumber","txtMobilePhoneExchange");
                if ( eExchange != "" ) 
               {
                if ( !ValidateExchangeMobilePhone( eExchange ))
        	        {
        	            return false;
        	        }
        	    }	
        	    
        	    var ePhoneNumber = GetCurrentControlValue("divMobileNumber","txtMobilePhoneLast4Digits");
                if ( ePhoneNumber != "" ) 
                {
        	        if ( !ValidateMobilePhoneNumber( ePhoneNumber ))
        	        {
        	            return false;
        	        }
        	    }	
             
                var ePhoneNumber = GetCurrentControlValue("divMobileNumber","txtMobilePhoneAreaCode") +
                    GetCurrentControlValue("divMobileNumber","txtMobilePhoneExchange") +
                    GetCurrentControlValue("divMobileNumber","txtMobilePhoneLast4Digits");        
                if ( ePhoneNumber != "" ) 
                {
        	        if ( !ValidateMobilePhone( ePhoneNumber ))
        	        {
        	            return false;
        	        }
        	    }	
        	    
        	    	    
        //	    var eDropDownTeam = GetCurrentControlValue("divMobileNumber","ddlFavoriteTeam");
        //	    if ( eDropDownTeam == "Choose..." )
        //	    {	    
        //            
        //            ProcessInvalidTeamChoice();
        //            return false;
        //        }
        //        
    }
        var emailID = GetCurrentControlValue("divUserEmail","txtUserEmail");            
	    if ( !ValidateEMail(emailID) )
	    {
	        return false;
	    }    	
	    
	    var eZipCode = GetCurrentControlValue("divUserZip","txtUserZip");
	    if ( eZipCode == "ZipCode*" )
	    {
	        ProcessInvalidZipCode();
		    return false;
	    }
	    
	    if ( !ValidateZipCode( eZipCode ) )
	    {
	        return false;
	    }
    	
	    //var eUserName = document.getElementById("txtUserName");
	    var eUserName = GetCurrentControlValue("divUserName","txtUserName");
	    
	    if ( eUserName == "Name*" )
	    { 
	        ProcessBlankUserName();	    
		    return false;
	    }
	    if ( !ValidateUserName( eUserName ))
	    {
	        return false;
	    }	
	    
	    
	
//	var temp = document.getElementById("divDisplayErrorMessages");
//	temp.style.display="";
//	var master = document.getElementById("divInsiderAlertsEmail");
//	master.style.display="none";
	return true;
 }
 

 function toggleLayer() 
 {         
   var temp = document.getElementById("divDisplayErrorMessages");
   if(temp.style.display!="") 
   {
      temp.style.display="";
      //document.myform.mybutton.value="Hide";
      
   }
   else 
   {
      //temp.style.display="none";
      //document.myform.mybutton.value="Toggle";
      var divEmailMsg = document.getElementById("divInsiderAlertsEmail");
		divEmailMsg.style.display= "";	
		
	    ClearAllMessageDivs();
   }
}


   
   function ClearAllMessageDivs()
   {
    
        var divEmailErrorMsg = document.getElementById("divEmailAddressIsARequiredField");
		divEmailErrorMsg.style.display="none";
    
		var divEmailErrorMsg = document.getElementById("divErrorEmailAddressInvalid");
		divEmailErrorMsg.style.display="none";
		
		var divEmailErrorMsg = document.getElementById("divMobilePhoneIsInvalid");
		divEmailErrorMsg.style.display="none";
		
		var divEmailErrorMsg = document.getElementById("divChooseATeam");
		divEmailErrorMsg.style.display="none";
    
		var divUserNameErrorMsg = document.getElementById("divUserNameIsARequiredField");
		divUserNameErrorMsg.style.display="none";
    
		var divZipCodeErrorMsg = document.getElementById("divZipCodeIsARequiredField");
		divZipCodeErrorMsg.style.display="none";
	
		var divErrorZipCodeErrorMsg = document.getElementById("divErrorZipCodeInvalid");
		divErrorZipCodeErrorMsg.style.display="none";
		
		var divDisplayErrorMessages = document.getElementById("divDisplayErrorMessages");
		divDisplayErrorMessages.style.display="none";
		
   }
   
   

// ***************************************************************
//
//THIS Is for the Create Subscriber control.
//
// ***************************************************************

function ValidateSubscriberEMail(emailID)
{
   
    if ((emailID==null)||(emailID==""))
	{	  	    
	    ProcessSubscriberBlankEmail();	    
		return false;		
	}
	
	if ( CheckEmailRegExpression(emailID) == false)
	{	  	    	    
	    ProcessSubscriberInvalidEmail();
		return false;
	}	
	return true;
}

function ValidateSubscriberZipCode(eZipCode)
{
    if ((eZipCode==null)||(trim(eZipCode)==""))
	{	   
	    ProcessSubscriberBlankZipCode();	    
		return false;		
	}
	
	//if ( CheckZipCodeRegExpression(eZipCode) == false)
	if ( CheckZipCode(eZipCode) == false )
	{
	    ProcessSubscriberInvalidZipCode();
		return false;
	}	
	return true;
}

function ValidateSubscriberUserName(eUserName)
{
    if ((eUserName==null)||(trim(eUserName)==""))
	{	   
	    ProcessSubscriberBlankUserName();	    
		return false;		
	}
	return true;
}

function ValidateSubscriberAreaCodeMobilePhone(phone)
{
	
	var phoneRegxp = new RegExp("^\\d{3}$");
        
    //THIS IS THE KEY TO THE RegX expression. Remember, you need to check the string value.
    //Also, remember to escape the \ characters with another slash. \\
    //var emailRegxp = new RegExp("^\\d{5}");
    var boolValue = phoneRegxp.test(phone);
        
    if ( !boolValue )    
    {
        ProcessSubscriberInvalidMobilePhone();
		
        return false;
    }
    return true;  
}

function ValidateSubscriberMobilePhoneNumber(phone)
{
    var phoneRegxp = new RegExp("^\\d{4}$");
        
    //THIS IS THE KEY TO THE RegX expression. Remember, you need to check the string value.
    //Also, remember to escape the \ characters with another slash. \\
    //var emailRegxp = new RegExp("^\\d{5}");
    var boolValue = phoneRegxp.test(phone);
        
    if ( !boolValue )    
    {
        ProcessSubscriberInvalidMobilePhone();
        return false;
    }
    return true;  
}

function ValidateSubscriberExchangeMobilePhone(phone)
{
    var phoneRegxp = new RegExp("^\\d{3}$");    
        
    //THIS IS THE KEY TO THE RegX expression. Remember, you need to check the string value.
    //Also, remember to escape the \ characters with another slash. \\
    //var emailRegxp = new RegExp("^\\d{5}");
    var boolValue = phoneRegxp.test(phone);
        
    if ( !boolValue )    
    {
        ProcessSubscriberInvalidMobilePhone();
        return false;
    }
    return true;  
}

function ValidateSubscriberMobilePhone(phone)
{
    if ( CheckPhoneRegExpression(phone) == false)
	{	  	    
	    ProcessSubscriberInvalidMobilePhone();
		return false;
	}	
	return true;
}

function ProcessSubscriberInvalidMobilePhone()
{            
		var divErrorMsg = document.getElementById("divDisplaySubscriberErrorMessages");		
		divErrorMsg.style.display= "";
		var divEmailErrorMsg = document.getElementById("divSubscriberMobilePhoneIsInvalid");
		divEmailErrorMsg.style.display="";
		
		var divEmailMsg = document.getElementById("divInsiderSubscriberAlertsEmail");
		divEmailMsg.style.display= "none";		
		
}	


function ProcessSubscriberBlankEmail()
{    
		var divErrorMsg = document.getElementById("divDisplaySubscriberErrorMessages");
		divErrorMsg.style.display= "";
		var divEmailErrorMsg = document.getElementById("divSubscriberEmailAddressIsARequiredField");
		divEmailErrorMsg.style.display="";
		var divEmailMsg = document.getElementById("divInsiderSubscriberAlertsEmail");
		divEmailMsg.style.display= "none";		
}	

function ProcessSubscriberInvalidEmail()
{    
        
		var divErrorMsg = document.getElementById("divDisplaySubscriberErrorMessages");		
		divErrorMsg.style.display= "";
		
		var divEmailErrorMsg = document.getElementById("divSubscriberEmailAddressInvalid");
		divEmailErrorMsg.style.display="";
		
		var divEmailMsg = document.getElementById("divInsiderSubscriberAlertsEmail");
		divEmailMsg.style.display= "none";		
		
}	

function ProcessSubscriberBlankZipCode()
{    
		var divErrorMsg = document.getElementById("divDisplaySubscriberErrorMessages");
		divErrorMsg.style.display= "";
		
		var divEmailErrorMsg = document.getElementById("divSubscriberZipCodeIsARequiredField");
		divEmailErrorMsg.style.display="";
		
		var divEmailMsg = document.getElementById("divInsiderSubscriberAlertsEmail");
		divEmailMsg.style.display= "none";
			
}	

function ProcessSubscriberInvalidZipCode()
{    
		var divErrorMsg = document.getElementById("divDisplaySubscriberErrorMessages");
		divErrorMsg.style.display= "";
		var divEmailErrorMsg = document.getElementById("divSubscriberErrorZipCodeInvalid");
		divEmailErrorMsg.style.display="";
		var divEmailMsg = document.getElementById("divInsiderSubscriberAlertsEmail");
		divEmailMsg.style.display= "none";		
}	

function ProcessSubscriberBlankUserName() {
   // alert('ProcessSubscriberBlankUserName');
		var divErrorMsg = document.getElementById("divDisplaySubscriberErrorMessages");
		divErrorMsg.style.display= "";
		var divEmailErrorMsg = document.getElementById("divSubscriberUserNameIsARequiredField");
		divEmailErrorMsg.style.display="";
		var divEmailMsg = document.getElementById("divInsiderSubscriberAlertsEmail");
		divEmailMsg.style.display= "none";		
}	
 
function ValidateSubscriberForm()
{       
        
        var chkMobileNumber = GetCheckBox("divMobileNumber","chkMobileNumber");
        if ( chkMobileNumber == true )
        {
            var eAreaCode = GetCurrentControlValue("divMobileNumber","txtMobilePhoneAreaCode");
            var eExchange = GetCurrentControlValue("divMobileNumber","txtMobilePhoneExchange");
            var ePhoneNumber = GetCurrentControlValue("divMobileNumber","txtMobilePhoneLast4Digits");
            if (( eAreaCode == "" ) || (eExchange == "") || (ePhoneNumber == "") )
            {
                ProcessSubscriberInvalidMobilePhone();
                return false;
            }
        }

        var eAreaCode = GetCurrentControlValue("divMobileNumber","txtMobilePhoneAreaCode");
        if ( eAreaCode != "" ) 
        {
	        if ( !ValidateSubscriberAreaCodeMobilePhone( eAreaCode ))
	        {
	            return false;
	        }
	    }	
	    
	    var eExchange = GetCurrentControlValue("divMobileNumber","txtMobilePhoneExchange");
        if ( eExchange != "" ) 
        {
	        if ( !ValidateSubscriberExchangeMobilePhone( eExchange ))
	        {
	            return false;
	        }
	    }	
	    
	    var ePhoneNumber = GetCurrentControlValue("divMobileNumber","txtMobilePhoneLast4Digits");
        if ( ePhoneNumber != "" ) 
        {
	        if ( !ValidateSubscriberMobilePhoneNumber( ePhoneNumber ))
	        {
	            return false;
	        }
	    }	
     
        var ePhoneNumber = GetCurrentControlValue("divMobileNumber","txtMobilePhoneAreaCode") +
            GetCurrentControlValue("divMobileNumber","txtMobilePhoneExchange") +
            GetCurrentControlValue("divMobileNumber","txtMobilePhoneLast4Digits");        
        if ( ePhoneNumber != "" ) 
        {
	        if ( !ValidateSubscriberMobilePhone( ePhoneNumber ))
	        {
	            return false;
	        }
	    }	   
     
        var emailID = GetCurrentControlValue("divSubscriberUserEmail","txtSubscriberUserEmail");    
	    if ( !ValidateSubscriberEMail(emailID) )
	    {
	        return false;
	    }    	
	 
	    var eZipCode = GetCurrentControlValue("divSubscriberUserZip","txtSubscriberUserZip");
	    if ( !ValidateSubscriberZipCode( eZipCode ) )
	    {
	        return false;
	    }
      	
	    //var eUserName = document.getElementById("txtUserName");
	    var eUserName = GetCurrentControlValue("divSubscriberUserName","txtSubscriberUserName");
	    if ( !ValidateSubscriberUserName( eUserName ))
	    {
	        return false;
	    }		   
	
//	var temp = document.getElementById("divDisplaySubscriberErrorMessages");
//	temp.style.display="";	
//	
//	
//	var master = document.getElementById("divInsiderSubscriberAlertsEmail");
//	if (master != undefined)
//	{
//	    alert(master);
//	    //master.style.display="none";
//	}

	
	return true;
 }

function toggleSubscriberLayer() 
 {         
   var temp = document.getElementById("divDisplaySubscriberErrorMessages");
   
   if(temp.style.display!="") 
   {
      temp.style.display="";
      //document.myform.mybutton.value="Hide";
      
   }
   else 
   {
        
      temp.style.display="none";
      //document.myform.mybutton.value="Toggle";
      var divEmailMsg = document.getElementById("divInsiderSubscriberAlertsEmail");
		divEmailMsg.style.display= "";			
	    ClearAllSubscriberMessageDivs();	    
   }
}
   
   function ClearAllSubscriberMessageDivs()
   {
        var divEmailErrorMsg = document.getElementById("divSubscriberEmailAddressIsARequiredField");
		divEmailErrorMsg.style.display="none";
		var divEmailErrorMsg = document.getElementById("divSubscriberEmailAddressInvalid");
		divEmailErrorMsg.style.display="none";
		
		var divUserNameErrorMsg = document.getElementById("divSubscriberUserNameIsARequiredField");
		divUserNameErrorMsg.style.display="none";
				
		var divZipCodeErrorMsg = document.getElementById("divSubscriberZipCodeIsARequiredField");
		divZipCodeErrorMsg.style.display="none";
		var divErrorZipCodeErrorMsg = document.getElementById("divSubscriberErrorZipCodeInvalid");
		divErrorZipCodeErrorMsg.style.display="none";
   } 
  

 

// ***************************************************************
//
//THIS Is for the LeftNav Insider control.
//
// ***************************************************************

function ValidateLeftNavEMail(emailID)
{
   
    if ((emailID==null)||(emailID==""))
	{	  	    
	    ProcessLeftNavBlankEmail();	    
		return false;		
	}
	
	if ( CheckEmailRegExpression(emailID) == false)
	{	  	    	    
	    ProcessLeftNavInvalidEmail();
		return false;
	}	
	return true;
}

function ValidateLeftNavZipCode(eZipCode)
{
    if ((eZipCode==null)||(eZipCode==""))
	{	   
	    ProcessLeftNavBlankZipCode();	    
		return false;		
	}
	
	//if ( CheckZipCodeRegExpression(eZipCode) == false)
	if ( CheckZipCode( eZipCode) == false )
	{
	    ProcessLeftNavInvalidZipCode();
		return false;
	}	
	return true;
}

function ValidateLeftNavUserName(eUserName)
{
    if ((eUserName==null)||(trim(eUserName)==""))
	{	   
	    ProcessLeftNavBlankUserName();	    
		return false;		
	}
	return true;
}

function ProcessLeftNavBlankEmail()
{    
		var divErrorMsg = document.getElementById("divDisplayLeftNavErrorMessages");
		divErrorMsg.style.display= "";
		var divEmailErrorMsg = document.getElementById("divLeftNavEmailAddressIsARequiredField");
		divEmailErrorMsg.style.display="";
		var divEmailMsg = document.getElementById("divInsiderLeftNavAlertsEmail");
		divEmailMsg.style.display= "none";		
}	

function ProcessLeftNavInvalidEmail()
{    
        
		var divErrorMsg = document.getElementById("divDisplayLeftNavErrorMessages");		
		divErrorMsg.style.display= "";
		
		var divEmailErrorMsg = document.getElementById("divLeftNavEmailAddressInvalid");
		divEmailErrorMsg.style.display="";
		
		var divEmailMsg = document.getElementById("divInsiderLeftNavAlertsEmail");
		divEmailMsg.style.display= "none";		
		
}	

function ProcessLeftNavBlankZipCode()
{    
		var divErrorMsg = document.getElementById("divDisplayLeftNavErrorMessages");
		divErrorMsg.style.display= "";
		
		var divEmailErrorMsg = document.getElementById("divLeftNavZipCodeIsARequiredField");
		divEmailErrorMsg.style.display="";
		
		var divEmailMsg = document.getElementById("divInsiderLeftNavAlertsEmail");
		divEmailMsg.style.display= "none";
			
}	

function ProcessLeftNavInvalidZipCode()
{    
		var divErrorMsg = document.getElementById("divDisplayLeftNavErrorMessages");
		divErrorMsg.style.display= "";
		var divEmailErrorMsg = document.getElementById("divLeftNavErrorZipCodeInvalid");
		divEmailErrorMsg.style.display="";
		var divEmailMsg = document.getElementById("divInsiderLeftNavAlertsEmail");
		divEmailMsg.style.display= "none";		
}	

function ProcessLeftNavBlankUserName()
{    
		var divErrorMsg = document.getElementById("divDisplayLeftNavErrorMessages");
		divErrorMsg.style.display= "";
		var divEmailErrorMsg = document.getElementById("divLeftNavUserNameIsARequiredField");
		divEmailErrorMsg.style.display="";
		var divEmailMsg = document.getElementById("divInsiderLeftNavAlertsEmail");
		divEmailMsg.style.display= "none";		
}	

function ProcessLeftNavInvalidMobilePhone()
{            
		var divErrorMsg = document.getElementById("divDisplayLeftNavErrorMessages");		
		divErrorMsg.style.display= "";
		var divEmailErrorMsg = document.getElementById("divLeftNavMobilePhoneIsInvalid");
		divEmailErrorMsg.style.display="";
		
		var divEmailMsg = document.getElementById("divInsiderLeftNavAlertsEmail");
		divEmailMsg.style.display= "none";		
		
}	

function fireButton(hfSubscribeClientID)
{
    
   
    if ( ValidateLeftNavForm() == false)
    {
        return false;
    }
    else
    {
        
        var hfSubscribe = document.getElementById(hfSubscribeClientID);
        hfSubscribe.value = "1";
        document.forms[0].submit();
        
        return true;
    }                                                              
}
 
function ValidateLeftNavForm()
{       
       
       var chkMobileNumber = GetCheckBox("divMobileNumber","chkMobileNumber");
        if ( chkMobileNumber == true )
        {
            var eAreaCode = GetCurrentControlValue("divMobileNumber","txtMobilePhoneAreaCode");
            var eExchange = GetCurrentControlValue("divMobileNumber","txtMobilePhoneExchange");
            var ePhoneNumber = GetCurrentControlValue("divMobileNumber","txtMobilePhoneLast4Digits");
            if (( eAreaCode == "" ) || (eExchange == "") || (ePhoneNumber == "") )
            {
                ProcessLeftNavInvalidMobilePhone();
                return false;
            }
        }
       
       var eAreaCode = GetCurrentControlValue("divMobileNumber","txtMobilePhoneAreaCode");
        if ( eAreaCode != "" ) 
        {
	        if ( !ValidateLeftNavAreaCodeMobilePhone( eAreaCode ))
	        {
	            return false;
	        }
	    }	
	    
	    var eExchange = GetCurrentControlValue("divMobileNumber","txtMobilePhoneExchange");
        if ( eExchange != "" ) 
        {
	        if ( !ValidateLeftNavExchangeMobilePhone( eExchange ))
	        {
	            return false;
	        }
	    }	
	    
	    var ePhoneNumber = GetCurrentControlValue("divMobileNumber","txtMobilePhoneLast4Digits");
        if ( ePhoneNumber != "" ) 
        {
	        if ( !ValidateLeftNavMobilePhoneNumber( ePhoneNumber ))
	        {
	            return false;
	        }
	    }	
     
        var ePhoneNumber = GetCurrentControlValue("divMobileNumber","txtMobilePhoneAreaCode") +
            GetCurrentControlValue("divMobileNumber","txtMobilePhoneExchange") +
            GetCurrentControlValue("divMobileNumber","txtMobilePhoneLast4Digits");        
        if ( ePhoneNumber != "" ) 
        {
	        if ( !ValidateLeftNavMobilePhone( ePhoneNumber ))
	        {
	            return false;
	        }
	    }	   
	    
       
        var emailID = GetCurrentControlValue("divLeftNavUserEmail","txtLeftNavUserEmail");  
        
	    if ( !ValidateLeftNavEMail(emailID) )
	    {
	        return false;
	    }    	
	    
	    var eZipCode = GetCurrentControlValue("divLeftNavUserZip","txtLeftNavUserZip");
	    if ( !ValidateLeftNavZipCode( eZipCode ) )
	    {
	        return false;
	    }
    	
	    //var eUserName = document.getElementById("txtUserName");
	    var eUserName = GetCurrentControlValue("divLeftNavUserName","txtLeftNavUserName");
	    if ( !ValidateLeftNavUserName( eUserName ))
	    {
	        return false;
	    }	
	
//	var temp = document.getElementById("divDisplayLeftNavErrorMessages");
//	temp.style.display="";
//	var master = document.getElementById("divInsiderLeftNavAlertsEmail");
//	master.style.display="none";
	return true;
 }
 
 function ValidateLeftNavAreaCodeMobilePhone(phone)
{
	
	var phoneRegxp = new RegExp("^\\d{3}$");
        
    //THIS IS THE KEY TO THE RegX expression. Remember, you need to check the string value.
    //Also, remember to escape the \ characters with another slash. \\
    //var emailRegxp = new RegExp("^\\d{5}");
    var boolValue = phoneRegxp.test(phone);
        
    if ( !boolValue )    
    {
        ProcessLeftNavInvalidMobilePhone();
		
        return false;
    }
    return true;  
}

function ValidateLeftNavMobilePhoneNumber(phone)
{
    var phoneRegxp = new RegExp("^\\d{4}$");
        
    //THIS IS THE KEY TO THE RegX expression. Remember, you need to check the string value.
    //Also, remember to escape the \ characters with another slash. \\
    //var emailRegxp = new RegExp("^\\d{5}");
    var boolValue = phoneRegxp.test(phone);
        
    if ( !boolValue )    
    {
        ProcessLeftNavInvalidMobilePhone();
        return false;
    }
    return true;  
}

function ValidateLeftNavExchangeMobilePhone(phone)
{
    var phoneRegxp = new RegExp("^\\d{3}$");    
        
    //THIS IS THE KEY TO THE RegX expression. Remember, you need to check the string value.
    //Also, remember to escape the \ characters with another slash. \\
    //var emailRegxp = new RegExp("^\\d{5}");
    var boolValue = phoneRegxp.test(phone);
        
    if ( !boolValue )    
    {
        ProcessLeftNavInvalidMobilePhone();
        return false;
    }
    return true;  
}

function ValidateLeftNavMobilePhone(phone)
{
    if ( CheckPhoneRegExpression(phone) == false)
	{	  	    
	    ProcessLeftNavInvalidMobilePhone();
		return false;
	}	
	return true;
}


function toggleLeftNavLayer() 
 {         
   var temp = document.getElementById("divDisplayLeftNavErrorMessages");
   if(temp.style.display!="") 
   {
      temp.style.display="";
      //document.myform.mybutton.value="Hide";
      
   }
   else 
   {
      temp.style.display="none";
      //document.myform.mybutton.value="Toggle";
      var divEmailMsg = document.getElementById("divInsiderLeftNavAlertsEmail");
		divEmailMsg.style.display= "";	
	    ClearAllLeftNavMessageDivs();
   }
}
   
   function ClearAllLeftNavMessageDivs()
   {
        var divEmailErrorMsg = document.getElementById("divLeftNavEmailAddressIsARequiredField");
		divEmailErrorMsg.style.display="none";
		var divEmailErrorMsg = document.getElementById("divLeftNavEmailAddressInvalid");
		divEmailErrorMsg.style.display="none";
		
		var divUserNameErrorMsg = document.getElementById("divLeftNavUserNameIsARequiredField");
		divUserNameErrorMsg.style.display="none";
		
		var divEmailErrorMsg = document.getElementById("divLeftNavMobilePhoneIsInvalid");
		divEmailErrorMsg.style.display="none";
		
		var divEmailErrorMsg = document.getElementById("divChooseATeam");
		divEmailErrorMsg.style.display="none";
				
		var divZipCodeErrorMsg = document.getElementById("divLeftNavZipCodeIsARequiredField");
		divZipCodeErrorMsg.style.display="none";
		var divErrorZipCodeErrorMsg = document.getElementById("divLeftNavErrorZipCodeInvalid");
		divErrorZipCodeErrorMsg.style.display="none";
   } 
  

